#define DEBUG
#include <cstdio>
#include <cmath>
#define MAXAB 1000000

using namespace std;

class Set {
public:
  int fa[MAXAB+1];

  void init(int n) {
    for (int i=1; i<=n; i++) {
      fa[i] = i;
    }
  }

  int getFa(int o) {
    if (fa[o]!=o) {
      fa[o] = getFa(fa[o]);
    }
    return fa[o];
  }
};

int max(int a, int b) {
  return a<b ? a : b;
}

int main() {
#ifdef DEBUG
  freopen("3.in", "r", stdin);
  freopen("3.out", "w", stdout);
#endif

  static long long num[MAXAB+1], mark[MAXAB+1];
  long long a, b, p;
  scanf("%lld %lld %lld", &a, &b, &p);
  for (long long i=a; i<=b; i++) {
    num[i-a+1]=i;
    mark[i-a+1]=2;
  }
  static Set set;
  set.init(b-a+1);
  for (int i=1; i<=b-a+1; i++) {
    for (long long j=mark[i]; j<=sqrt(num[i]); j++) {
      if (num[i]%j==0) {
	for (int k=i+j; k<=b-a+1; k+=j) {
	  for (; num[k]%j==0; num[k]/=j);
	  if (j>=p && set.getFa(i)!=set.getFa(k)) {
	    set.fa[set.getFa(k)] = set.getFa(i);
	  }
	}
      }
      for (; num[i]%j==0; num[i]/=j);
    }
    if (num[i]>=p) {
      for (int k=i+num[i]; k<=b-a+1; k+=num[i]) {
	for (; num[k]%num[i]==0; num[k]/=num[i]);
	if (set.getFa(i)!=set.getFa(k)) {
	  set.fa[set.getFa(k)] = set.getFa(i);
	}
      }
    }
    num[i]=1;
  }

  static bool book[MAXAB+1];
  int cnt=0;
  for (int i=1; i<=b-a+1; i++) {
    if (!book[set.getFa(i)]) {
      book[set.getFa(i)]=true;
      cnt++;
    }
  }
  printf("%d", cnt);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
